import argparse

import command


def git_clones():
    parser = argparse.ArgumentParser(description='git 批量拉取')
    parser.add_argument('-f', '--file', nargs='?', default='', help='git路径文件')
    args, unknown_args = parser.parse_known_args()
    file_path = args.file
    if len(unknown_args) > 0:
        file_path = unknown_args[0]

    f = open(file_path, mode="r", encoding="utf8")
    lines = f.readlines()
    for line in range(0, len(lines)):
        line_ = lines[line]
        line_ = line_.replace('\n', '')
        if len(line_) > 0:
            command_line = 'git clone %s' % line_
            command.exe_command(command_line)

    f.close()


if __name__ == '__main__':
    git_clones()
